home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr55 / cld9macp.zip / CLD9MACP.TXT
Text File  |  1993-06-08  |  78KB  |  2,041 lines

  1. Archive-name: macintosh/programmer-faq/part1
  2. Last-modified: 1993/01/12
  3.  
  4.  
  5.                      +---------------------------------+
  6.                      | Frequently Asked Questions List |
  7.                      |   for Comp.Sys.Mac.Programmer   |
  8.                      |         January 12, 1993        |
  9.                      |            PART  ONE            |
  10.                      +---------------------------------+
  11.  
  12.  
  13. This FAQ list is automatically posted once a week to comp.sys.mac.programmer.
  14. It is also available via anonymous ftp from ftp.cs.uoregon.edu [128.223.8.8]
  15. (user name 'anonymous', your internet address as password) in the files
  16. /pub/mac/csmp-faq-1 and /pub/mac/csmp-faq-2.
  17.  
  18. This FAQ list is maintained by Daryl Spitzer.  He can be reached at the
  19. following addresses:
  20.  
  21.    Internet:  Daryl_Spitzer@mindlink.bc.ca
  22.    SnailMail: 203 - 1385 West 12th Avenue
  23.               Vancouver, BC  (Canada)
  24.               V6H 1M2
  25.  
  26. The purpose of the FAQ list is to answer some of the most common questions
  27. asked on this group, and to refer people left with unanswered questions to
  28. available sources of additional help.  You should read the FAQ list before
  29. posting to comp.sys.mac.programmer.
  30.  
  31. Submissions, comments, etcetera, should be sent to Daryl Spitzer, as above.
  32. All such material sent will be considered to have entered the public domain
  33. (and will be subject to editing) unless specific text to the contrary
  34. accompanies the message (which may render the submission unusable).
  35.  
  36.  
  37.  
  38.                          Changes since August 3, 1992
  39.                          ----------------------------
  40.  
  41.  - the keeper of the FAQ is now Daryl Spitzer (Daryl_Spitzer@mindlink.bc.ca)
  42.  
  43.  - 1.2  Debuggers:
  44.     added Fritz Anderson's description of SourceBug
  45.  
  46.  - 2.1  The Associates and Partners Programs:
  47.     new description, DEVHOTLINE is no longer a valid AppleLink address
  48.  
  49.  - 2.3  APDA
  50.     new address and telephone numbers
  51.  
  52.  - 3.1.1  Technical Books
  53.     new Inside Macintosh volumes
  54.  
  55.  - 3.1.3  Periodicals:
  56.     MacTutor is now MacTech
  57.  
  58.  
  59.  
  60.  
  61.                              Table of Contents
  62.                               -----------------
  63.  
  64. Part One  (this file)
  65. ---------------------
  66.  
  67.   I.    Development Software
  68.           1. Compilers
  69.           2. Debuggers
  70.           3. Other Tools
  71.  
  72.   II.   Apple Developer Programs
  73.           1. The Associates and Partners Programs
  74.           2. Apple Developer University
  75.           3. APDA
  76.           4. Developer CDs
  77.  
  78.   III.  Sources of Information
  79.           1. Books and Periodicals
  80.                1. Technical Books
  81.                2. Teaching Books
  82.                3. Periodicals
  83.           2. Mailing Lists
  84.                1. Comp.Sys.Mac.Programmer Digest
  85.                2. Think Class Library Discussion
  86.                3. MacPsych
  87.           3. Miscellaneous
  88.                1. Usenet Mac Programmer's Guide (UMPG)
  89.                2. Kent Sandvik's Frequently Asked MPW C++ and MacApp
  90. Questions
  91.                3. Comp.Sys.Mac.FAQ
  92.  
  93.   IV.   Archive Sites
  94.           1. ftp.apple.com [130.43.2.3]
  95.           2. sumex-aim.stanford.edu [36.44.0.6]
  96.           3. rascal.ics.utexas.edu [128.83.138.20]
  97.           4. mac.archive.umich.edu [141.211.164.153]
  98.           5. ftp.cs.uoregon.edu [128.223.8.8]
  99.           6. ics.uci.edu [128.195.1.1]
  100.           7. ftp.brown.edu [128.148.176.55]
  101.           8. comp.binaries.mac [newsgroup]
  102.  
  103.   V.    One-liners
  104.           1. The Main Loop and Events
  105.           2. Menus
  106.           3. Resources
  107.           4. Windows, Alerts, and Dialogs
  108.           5. Drawing
  109.           6. Files
  110.           7. Interrupts and VBL Tasks
  111.           8. Handles and Pointers
  112.           9. General
  113.  
  114.  
  115. Part Two  (separate file)
  116. -------------------------
  117.  
  118.   VI.   Specific Questions Answered
  119.           1. The Main Loop and Events
  120.                1. How do you tell if a specific key is being pressed?
  121.                2. How can I get millisecond timing from the keyboard
  122.                   (or mouse)?
  123.           2. Menus
  124.                1. When do you put an ellipsis on the end of a menu item?
  125.                2. How do I get the menubar to disappear and re-appear?
  126.                3. What's the difference between the resource ID of a 'MENU'
  127.                   resource and the menuID field of that resource?
  128.           3. Windows, Alerts, and Dialogs
  129.                1. How do you put a border around the default button in a
  130.                   dialog?
  131.           4. Drawing
  132.                1. What is the fastest way to paint one pixel on the screen?
  133.                2. How do you draw directly into a pixmap without using
  134.                   QuickDraw?
  135.                3. How do you draw directly onto the screen without using
  136.                   QuickDraw?
  137.                4. What RGB value does the system use for dimmed buttons,
  138.                   menus and window titles?
  139.           5. Files
  140.                1. Why is the File Manager so hard to use?
  141.                2. How do you get a full pathname?
  142.                3. How do you set the SFGet/PutFile directory?
  143.                4. How do you access the application's data fork?
  144.           6. Handles and Pointers
  145.                1. When should I call MoveHHi?
  146.                2. Why does malloc/calloc keep crashing or returning NULL in
  147.                   Think C?
  148.           7. Standalone Code
  149.                1. How do I write an INIT?
  150.           8. General
  151.                1. How do I register signatures and file types with Apple?
  152.                2. How do I go about writing serial port communications?
  153.  
  154.  
  155.   VII.  Eternal Debates:
  156.           1. Why doesn't the Mac do preemptive multitasking?
  157.  
  158.  
  159.  
  160. =============================================================================
  161.  
  162.  
  163.                      ===================================
  164.                        Section I: Development Software
  165.                      ===================================
  166.  
  167.  
  168. This is by no means a complete analysis of the tools, development systems,
  169. etc. that are available.  This is a short list of things which *most* Mac
  170. programmers use (or are at least aware of, and have considered using).
  171.  
  172.  
  173.  
  174. 1.1  Compilers
  175. --------------
  176.  
  177. Macintosh Programmer's Workshop (Apple)
  178. ---------------------------------------
  179.  
  180. MPW is a package which contains separately-purchaseable compilers for
  181. Assembly, C, C++, and Object Pascal.  All of these run in an environment
  182. called the MPW Shell.  The Shell is a command-line oriented environment,
  183. designed for extreme configurability with scripts, user-writeable "tools",
  184. i/o redirection, and lots of other bells and whistles.  On the pro side, it
  185. can do many things that THINK cannot do; it scales much better to large
  186. projects; it can be customized much more; and it's Apple's supported
  187. development environment.  On the con side, it is comparatively expensive,
  188. slow, and difficult to learn.  A debugger (SADE) is available for it, and
  189. is philosophically similar to MPW.  An object library is available (MacApp)
  190. which allows applications to be built on an object-oriented framework, again
  191. similar to MPW in it's approach of being very powerful, but not necessarily
  192. easy to learn, easy to use, small, or fast.
  193.  
  194. MPW is also available on the quarterly Essentials-Tools-Objects CD-ROM from
  195. Apple.  This disc contains the latest version of the entire MPW development
  196. environment, as well as debugging utilities and a huge collection of sample
  197. source code.  This brings the price of the MPW environment down a bit, but
  198. it's still much more expensive than THINK.
  199.  
  200.  
  201. Think (Symantec)
  202. ----------------
  203.  
  204. Think is two separate products, Think C and Think Object Pascal.  They are
  205. similar products.  Both are integrated editor/compiler/linker/debugger
  206. environments.  Both come with a large library of predefined classes (the C
  207. classes are written in a sort of pseudo C++ language that is Symantec's own
  208. Object C, not C++).  Think Pascal is MacApp-compatable, as well.  Both
  209. support inline assembly, but there is no separate assembler.  Their main
  210. selling point, however, is that they are very fast and very simple.  They are
  211. ideal for small projects that you want to finish in a few days, for
  212. beginners, and for people who need a full-fledged development environment but
  213. cannot afford MPW.  This is not to say that the Think environments are not
  214. useful for commercial development; many successful commercial programs were
  215. written with Think.  The difference in power between MPW and Think is only
  216. noticeable with very large and/or multiple-developer projects.
  217.  
  218.  
  219.  
  220. 1.2  Debuggers (beyond SADE and the Think debuggers)
  221. ----------------------------------------------------
  222.  
  223. MacsBug (Apple)
  224. ---------------
  225.  
  226. MacsBug is an assembly-level debugger.  It is a command-line driven, entirely
  227. text-based environment which uses little of the Mac toolbox, and is thus
  228. fairly stable in crashes (although it doesn't use protected memory, its main
  229. failing in the area of stability).  It supports complex operations with
  230. breakpoints, A-line traps, macros, expressions, and more, and can be
  231. configured even more with user-writeable 'dcmd' external code resources.
  232. MacsBug is free via anonymous ftp from ftp.apple.com.  It is also included
  233. with the book "Debugging Macintosh Software with MacsBug."
  234.  
  235.  
  236. TMON Professional (ICOM)
  237. ------------------------
  238.  
  239. TMON Professional is an object-level debugger which is MUCH more powerful
  240. than MacsBug.  It has an elaborate interface which looks nothing like a Mac
  241. application, and takes a while to get used to.  It is a very intelligent
  242. program, however, which can often display memory in its most useful format
  243. without help (e.g. it will disassemble code, and display a string as a
  244. string, automatically).  It has strong support for types, allowing you to
  245. easily view complex structures, arrays, floating point numbers, and more.
  246. You can examine the stack, the heaps, and just about anything else you could
  247. be interested in.  It also provides versatile scripting, and is amazingly
  248. configurable.  There are more goodies in this package than I can possible
  249. describe here.  Drawbacks are high price, and a very steep learning curve.
  250.  
  251.  
  252. The Debugger (Jasik Designs)
  253. ----------------------------
  254.  
  255. The Debugger (also known as Jasik's Debugger, because it was written by Steve
  256. Jasik) is the only source level debugger with all the low-level features of
  257. Macsbug (speed, straight-forward display of important info) and many of the
  258. advantages of source level debuggers (source code, quick display of local
  259. variables).  Some of its best features are complete support for Object
  260. Pascal, speed, and the ability to look at resource map and file information.
  261. You gotta love any debugger that will display all of the low-level globals
  262. with their values in a single keystroke!  It also has a On the down side,
  263. the interface is an aquired taste, the documentation needs work and
  264. distribution disks lack a certain polish.  But, phone support is very good
  265. (you often get Steve himself).
  266.  
  267.  
  268. SourceBug (Apple)
  269. -----------------
  270.  
  271. SourceBug is provided by Apple on its ETO development-tools CD.  Like SADE,
  272. SourceBug is a source-level debugger.  SADE is a scriptable,
  273. stream-in/stream-out environment like MPW: The code being debugged is
  274. displayed in text windows, with the current line highlighted.  Data
  275. structures
  276. can be inspected, but only through printing commands; the formatting is
  277. automatic and type-sensitive.  And, you can use scripts to walk linked or
  278. array data structures automatically, and save the results to text files.
  279.  
  280. SourceBug, by contrast, is driven by mouse selections and menu commands.  The
  281. program is centered around a browser window that organizes your code by
  282. source
  283. file (or by type, if you are using C++ or Object Pascal) and module name.
  284. You
  285. set breakpoints by clicking next to the line you want to break at.  SADE
  286. requires a command to set breakpoints (though a menu item front-ends a script
  287. to set simple ones by selection); on the other hand, a SADE breakpoint can
  288. execute any script, permitting snapshots and conditional breaks.  SourceBug
  289. gives you only an unconditional break.
  290.  
  291. The same dichotomy applies to data structures:  SourceBug is nearly as smart
  292. as SADE in parsing data, and provides you with an inspector for most
  293. instances
  294. of C++ or Pascal objects.  But finding data, link traversals, and some
  295. formatting are strictly manual jobs.  Variable-length arrays of complex
  296. types?
  297. Forget it.  SADE can handle them, SourceBug can't.
  298.  
  299. For most purposes, SourceBug is the better debugger.  It is rare that you
  300. need
  301. SADE's strengths badly enough to compose the suite of breakpoints and testing
  302. scripts you will need to make SADE effective.  SourceBug is better at 99% of
  303. the debugging tasks:  For instance, when you break into SourceBug, the
  304. currently-executing procedure is displayed in a window, with an arrow
  305. pointing
  306. to the current line.  In the upper part of the window is the stack crawl;
  307. click on any item in the list to see any procedure in the calling chain, see
  308. the line that made the call, and inspect (the optimizer permitting) the local
  309. variables of any procedure in the chain.  To do the same in SADE requires
  310. issuing a command to dump the stack and selecting a code address identifier
  311. in
  312. the result.  To examine a variable in use by a caller, you will have to use
  313. SADE's scoping language to provide it with enough context to identify the
  314. address.  SADE can do more, but it can't carry enough context to be as
  315. helpful
  316. as SourceBug.
  317.  
  318.  
  319.  
  320. 1.3  Other Tools
  321. ----------------
  322.  
  323. ResEdit (Apple)
  324. ---------------
  325.  
  326. ResEdit is the accepted tool for editing and creating resources.  It has very
  327. little competition, partially because it is a very good and comprehensive
  328. program, and partially because it is free (available via anonymous ftp from
  329. ftp.apple.com).  It allows you to edit any resource in hexadecimal, and most
  330. of the standard types have special editors that provide a direct-manipulation
  331. paradigm for editing them.  Users may write their own pickers and editors for
  332. custom resource types, although this is rarely done in practice.
  333.  
  334.  
  335. Resorcerer (Mathemaesthetics)
  336. ------------------------------
  337.  
  338. Resorcerer is a commercially available replacement for ResEdit.  Many
  339. developers use it exclusively, and swear by it quite vehemently.  This is
  340. from one of them:
  341.  
  342.       RESORCERER is a no-holds-barred resource dynamo.
  343.         -- embarrasses the ResEdit dialog editor
  344.         -- supports many more template data types
  345.         -- swap in different resource templates based on a key value
  346.         -- creates recursive resources
  347.         -- generates starter code for a dialog
  348.         -- does complex searches against resource contents or titles
  349.         -- renumbers resources in batches
  350.         -- changes resource types
  351.         -- excellent support from the author himself
  352.  
  353. I personally like Resorcerer for some things and ResEdit for others.  There
  354. are certain resource types that cannot be edited with Resorcerer, like
  355. color icons, and others that cannot be edited with ResEdit, like help
  356. balloons.  I expect, however, that with the addition of such resource
  357. editors to Resorcerer, I will begin to use it exclusively.
  358.  
  359. The price is the major consideration for most people.  ResEdit is free from
  360. Apple, while Resorcerer is a commercial product (available for around $250).
  361.  
  362.  
  363. Virtual User (Apple)
  364. --------------------
  365.  
  366. Virtual User allows you to script user interactions with a program so that
  367. they cal be relayed over and over, and it can execute scripts remotely, over
  368. AppleTalk.  So, for instance, you could write a script that puts your program
  369. through its paces, and then automatically execute that script simultaneously
  370. on lots of differently configured Macintosh systems.  It is available from
  371. APDA (#M0987LL/B).  [This paragraph taken from develop Issue 8, page 60.]
  372.  
  373.  
  374. Online Companion (Addison-Wesley)
  375. ---------------------------------
  376.  
  377. Online Companion is a reference tool.  Hit a magic key combination, and a
  378. pseudo-window opens at the bottom of the screen which allows you to type in
  379. a full or partial name and find it in Online's database.  It contains Inside
  380. Mac and some supplements, Tech Notes, etc.  It's fast and simple.
  381.  
  382.  
  383. Think Reference (Symantec)
  384. --------------------------
  385.  
  386. Think Reference is a reference tool.  It is a hypertext version of Inside Mac
  387. I-V and the Tech Notes.  Click on the function or data type name to go to the
  388. page on which it is defined.  It includes some very useful notes and examples
  389. written by Symantec, and the function prototypes can be copied and pasted
  390. into your editor.  Very fast and simple to use.  But beware of typos and, in
  391. some cases, bad advice.
  392.  
  393.  
  394.  
  395.  
  396.  
  397.                    ========================================
  398.                      Section II: Apple Developer Programs
  399.                    ========================================
  400.  
  401.  
  402. 2.1  The Associates and Partners Programs
  403. -----------------------------------------
  404.  
  405. From the Macintosh Development Tools and Languages Guidebook
  406. (1993 Edition, page 15):
  407.  
  408. The Apple Associates Program is Apple's mainstream program for qualified
  409. commercial developers whose plans are well-aligned to Apple's long-term
  410. strategy.  Members of this program receive essential technical and
  411. marketing information, as well as self-help technical support tools.
  412. Eligible Apple Associates can also purchase, at special prices, a limited
  413. number of Apple systems for development purposes.
  414.  
  415. The Apple Partners Program is a development support program for
  416. Apple-selected commercial developers.  Apple Partners haves access to
  417. programs and services such as techical and marketing information, as well
  418. as direct technical support via electronic mail.  Apple Partners can also
  419. purchase, at special prices, a limited number of Apple computer systems
  420. for development purposes.
  421.  
  422. Apple Associates and Apple Partners receive a monthly mailing containing
  423. all of the information in the Technical Information Mailing.  [see section
  424. 2.4]  Two other particularly interesting products that are included are
  425. the Developer CD, which contains hundreds of megabytes of
  426. programming-related material, and Apple Direct, a newspaper that keeps
  427. developers abreast of Apple's technical developments and marketing
  428. directions.
  429.  
  430. Apple Associates and Apple Partners also get product-level support on
  431. development tools and system software, and information on how to use
  432. Apple's resources most efficiently.  Additionally, code-level support
  433. from Developer Technical Support is available to Apple Partners via
  434. electronic mail.
  435.  
  436. For more information on support programs for commercial developers
  437. contact the Developer Hotline at:
  438.  
  439. Developer Support
  440. Apple Computer Inc.
  441. 20525 Mariani Avenue, M/S 75-2C
  442. Cupertino, CA 95014
  443. (408) 974-4897
  444.  
  445. [no AppleLink address is given, but try DEVSUPPORT]
  446.  
  447.  
  448. 2.2  Apple Developer University
  449. -------------------------------
  450.  
  451. From the back cover of 'develop' Issue 7:
  452.  
  453. Apple Developer University provides training for all levels of Macintosh
  454. programmers.  The hands-on classes give you experience using the most up-
  455. to-date development tools.  Classes are offered in locations across the
  456. United States, and on-site instruction can also be arranged.  Multimedia
  457. self-paced courses are available from Developer University through APDA.
  458. These courses include Macintosh Programming Fundamentals, User-Centered
  459. Design, and Introduction to Object-Oriented Programming.
  460.  
  461. The registrar at (408) 974-6215 can reserve your place or send a current
  462. catalog.  You can also AppleLink DEVUNIV (devuniv@applelink.apple.com) or
  463. write
  464.  
  465.      20525 Mariani Avenue
  466.      M/S 75-6U
  467.      Cupertino, CA  95014
  468.  
  469.  
  470. 2.3  APDA
  471. ---------
  472.  
  473. From the Macintosh Development Tools and Languages Guidebook
  474. (1993 Edition, page 13):
  475.  
  476. APDA is an Apple service organization that offers convenient worldwide
  477. access to over 300 development tools, resources, training products, and
  478. information for anyone interested in developing applications on Apple
  479. platforms.  Customers receive the quarterly APDA Tools Catalog featuring
  480. alll of the most popular and most current versions of Apple tools and the
  481. most popular third-party development tools.  Ordering is easy, there are
  482. no membership fees and no special agreements are required for most products.
  483. APDA offers convenient payment and shipping options, including site
  484. licensing.
  485.  
  486. To order product or receive a complimentary APDA Tools Catalog, contact:
  487.  
  488.     APDA
  489.     Apple Computer Inc.
  490.     P.O. Box 319
  491.     Buffalo, New York 14207-0319 U.S.
  492.  
  493.     (800) 282-2732 U.S.
  494.     (800) 637-0029 Canada
  495.     (716) 871-6555 International
  496.     (716) 871-6511 Fax
  497.     APDA           AppleLink (apda@applelink.apple.com)
  498.     76666,2405     CompuServe
  499.     APDA           America Online
  500.  
  501.  
  502. 2.4  Developer CDs
  503. ------------------
  504.  
  505. The developer CDs are available quarterly from APDA, or monthly to Apple
  506. Associates and Partners.  The quarterly version is also included in the
  507. quarterly issue of d e v e l o p.  They contain just about everything that
  508. Apple makes freely available, including SpInside Mac, the Tech Notes, and
  509. a plethora of code snippets.
  510.  
  511.  
  512.  
  513.  
  514.  
  515.                    =======================================
  516.                      Section III: Sources of Information
  517.                    =======================================
  518.  
  519.  
  520. 3.1  Books and Periodicals
  521. --------------------------
  522.  
  523. 3.1.1  Technical Books
  524. ----------------------
  525.  
  526.  
  527. Inside Macintosh Volume I
  528.    Addison-Wesley.  ISBN 0-201-17731-5.  $24.95
  529. Inside Macintosh Volume II
  530.    Addison-Wesley.  ISBN 0-201-17732-3.  $24.95
  531. Inside Macintosh Volume III
  532.    Addison-Wesley.  ISBN 0-201-17733-1.  $19.95
  533. Inside Macintosh Volume IV
  534.    Addison-Wesley.  ISBN 0-201-05409-4.  $24.95
  535. Inside Macintosh Volume V
  536.    Addison-Wesley.  ISBN 0-201-17719-6.  $26.95
  537. Inside Macintosh Volume VI
  538.    Addison-Wesley.  ISBN 0-201-57755-0.  $39.95
  539.  
  540.      Inside Mac is the definitive reference regarding the Macintosh toolbox.
  541.      Volumes I and II are basically essential to any Mac programmer who uses
  542.      the toolbox at all.  Volume III is essentially a summary, cross
  543.      reference, index-y sort of thing, and isn't very useful.  Volume IV is
  544.      stuff specific to the Mac Plus and later machines, which would make it
  545.      almost as important as I and II (not many 512K Macs left out there),
  546.      except that the routines it describes are not nearly as generally
  547.      useful.  It does have all of the stuff on the HFS File Manager, however,
  548.      so if you're working with File Manager routines you should definitely
  549.      consult IV before I-III.  Otherwise, you can survive without it for a
  550.      while.  Volume V is the Mac II volume.  It has every thing on Color
  551.      QuickDraw, as well as lots of other goodies.  I'd say it's more useful
  552.      than IV, but only if you're doing color.  Volume VI is the System 7
  553.      volume.  It contains all kinds of bizarre new things which are probably
  554.      not of general use or interest; but it contains a lot of new
  555.      non-System-7 stuff as well (such as 32-bit Quickdraw), and it has
  556.      corrections to the other five volumes.
  557.  
  558.  
  559. Inside Macintosh X-Ref, Revised Edition
  560.    Addison Wesley.  ISBN 0-201-57769-0.  $12.95.
  561.  
  562.      Inside Mac X-Ref is a cross-referenced index to the six volumes and
  563.      some other Macintosh technical books.
  564.  
  565.  
  566. Inside Macintosh: Files      ISBN 0-201-63244-6     $29.95
  567. Inside Macintosh: Memory     ISBN 0-201-63240-3     $24.95
  568. Inside Macintosh: Processes  ISBN 0-201-63241-1     $22.95
  569.  
  570.      Inside Macintosh, having previously been three authoritative
  571.      volumes, with three chronological supplements, has been due for
  572.      a rewrite and overhaul for a few years.  Apple is now in the
  573.      process of reissuing IM in 15 subject-related books, of which
  574.      only the first three have come out at this writing.
  575.  
  576.      If you have volumes I-VI, then you will eventually have to buy
  577.      the new Inside Macintosh, too.  Newcomers are in a dilemma:
  578.      The new IM has better information than the old one, but not
  579.      enough of the new IM has come out to be useful.  They will have
  580.      to judge how urgent their need is for authoritative
  581.      information.  Dabblers and beginners can probably get by with
  582.      the teaching books recommended below.  Serious work begins with
  583.      Volume I (basic ToolBox), Volume II (basic OS), and Volume IV
  584.      (for the file system).  If you need color, get Volume V; if you
  585.      do anything with processes (IPC, backgrounding), get Volume VI.
  586.  
  587.  
  588. M68000 User's Manual
  589.    Prentice Hall.  ISBN 0-13-609249-7.  $22.95.
  590. MC68020 User's Manual
  591.    Prentice Hall.  ISBN 0-13-567017-9.  $22.95.
  592. MC68030 User's Manual
  593.    Prentice Hall.  ISBN 0-13-566423-3.  $22.95.
  594. MC68881/MC68882 Floating-Point Coprocessor User's Manual
  595.    Prentice Hall.  ISBN 0-13-566936-7.  $22.95.
  596.  
  597.      The Motorola references are required reading for anyone doing assembly
  598.      programming on the Mac.  The 68000 is by far the most important.  The
  599.      68881 manual only has relevance to those who want to do floating point
  600.      and don't want to use SANE (the Standard Apple Numeric Environment,
  601.      slow but robust, precise and general).
  602.  
  603.  
  604. Technical Introduction to the Macintosh Family
  605.    Addison-Wesley.  ISBN 0-201-17765-X.  $19.95.
  606.  
  607.      This book provides an overview of the general hardware design, system
  608.      archiecture, and ROM design of the Macintosh.  It is not required for
  609.      programming, but does provide some useful background information for
  610.      programmers new to the Mac.
  611.  
  612.  
  613. Programmer's Introduction to the Macintosh Family.
  614.    Addison-Wesley.  ISBN 0-201-19254-3.  $22.95.
  615.  
  616.      This book provides an overview of basic Macintosh programming concepts.
  617.      It is recommended for programmers new to the Mac.
  618.  
  619.  
  620. Guide to the Macintosh Family Hardware
  621.    Addison-Wesley.  ISBN 0-201-52405-8.  $26.95.
  622.  
  623.      This is the definitive guide to the hardware design of the Macintosh
  624.      family.
  625.  
  626.  
  627. Designing Cards and Drivers for the Macintosh Family
  628.    Addison-Wesley.  ISBN 0-201-52404-X.  $26.95.
  629.  
  630.      This is the official guide for developers of expansion cards and
  631.      peripheral devices for the Mac.  This book is required reading for
  632.      anyone who wants to talk directly to expansion cards (video cards,
  633.      for example).
  634.  
  635.  
  636. Human Interface Guidelines: The Apple Desktop Interface
  637.    Addison-Wesley.  ISBN 0-201-17753-6.  $14.95.
  638.  
  639.      This is the definitive guide to program interface design on the
  640.      Macintosh.  When you find yourself wondering where to put the OK
  641.      button in a dialog, consult this book.
  642.  
  643.  
  644. Apple Numerics Manual
  645.    Addison-Wesley.  ISBN 0-201-17738-2.  $29.95.
  646.  
  647.      This book describes the Standard Apple Numerics Environment (SANE),
  648.      and provides information about the IEEE-standard arithmetic and
  649.      about the SANE engines on the Apple IIgs and Macintosh computers.
  650.  
  651.  
  652. Inside the Macintosh Communications Toolbox
  653.    Addison-Wesley.  ISBN 0-201-57775-5.  $24.95.
  654.  
  655.      This is the definitive reference volume for the Communications Toolbox.
  656.  
  657.  
  658.  
  659. 3.1.2  Teaching Books
  660. ---------------------
  661.  
  662.  
  663. Macintosh Programming Primer (Second Edition)
  664.    Addison-Wesley.  ISBN 0-201-60838-3.  $26.95.
  665. Macintosh C Programming Primer Volume II
  666.    Addison-Wesley.  ISBN 0-201-57016-5.  $24.95.
  667.  
  668.      These are excellent books for the beginning Mac programmer.  Both books
  669.      use Think C in their examples, but developers using other platforms
  670.      will find a plethora of useful tidbits.  I believe both books are
  671.      available in Pascal as well.
  672.  
  673.  
  674. Macintosh Revealed, Volume One: Unlocking the Toolbox
  675.    Hayden Books.  ISBN 0-8104-6551-5.  $26.95.
  676. Macintosh Revealed, Volume Two: Programming with the Toolbox
  677.    Hayden Books.  ISBN 0-8104-6561-2.  $26.95.
  678. Macintosh Revealed, Volume Three: Mastering the Toolbox
  679.    Hayden Books.  ISBN 0-672-48402-1.  $26.95.
  680. Macintosh Revealed, Volume Four: Expanding the Toolbox
  681.    Hayden Books.  ISBN 0-672-48413-7.  $26.95.
  682.  
  683.      This encyclopedic collection covers the entire Mac Toolbox for the
  684.      beginning Pascal or Assembly programmer.  It sometimes re-iterates
  685.      Inside Mac, but always offers a fresh perspective.  Volume I covers
  686.      basics including memory management and QuickDraw.  Volume II covers the
  687.      other essential Toolbox managers and exemplifies each by constructing
  688.      part of a complete text editor.  Volume III expands this application,
  689.      covering printing, drivers, desk accessories, sound and definition
  690.      functions.  Volume IV contains details of programming with MultiFinder,
  691.      Color QuickDraw and styled text.
  692.  
  693.  
  694. How to Write Macintosh Software (Third Edition)
  695.    Hayden Books.  ISBN 0-201-?????-?.  ~$30.
  696.  
  697.      This book gives comprehensive coverage of memory management and
  698.      debugging techniques.  It also gives an excellent overview of assembly
  699.      language programming on the Mac.  A must-have.  Somebody please send me
  700.      the ISBN and price of the third edition (I haven't bought mine yet).
  701.  
  702.  
  703. Macintosh Programming Secrets (Second Edition)
  704.    Addison-Wesley.  ISBN 0-201-58134-5.  $29.95.
  705.  
  706.      This is the second edition of Scott Knaster's classic book.  This
  707.      edition was co-authored by Keith Rollin.  From the back cover: "If
  708.      you've ever written Macintosh programs, or want to learn how it's done,
  709.      this book will show you how to perform tasks that aren't explicitly
  710.      documented in the reference books."  This is true.  Get this book if
  711.      you want to learn how to write a tail patch, or how to hide the menu
  712.      bar.  If you don't know what a tail patch is, that's OK; this book
  713.      starts at (or near) the beginning.  A must-have for all beginning- and
  714.      intermediate-level Macintosh programmers.
  715.  
  716.  
  717. On Macintosh Programming: Advanced Techniques
  718.    Addison-Wesley.  ISBN 0-201-51737-X.  $24.95.
  719.  
  720.      This book contains a lot of information on all aspects of programming
  721.      the Mac, including hardware and software architecture, the toolbox,
  722.      and the use of assembly, C, and Pascal for programming the toolbox.
  723.      It includes quite a lot of source code.
  724.  
  725.  
  726. Using the Macintosh Toolbox With C
  727.    Sybex.  ISBN 0-89588-572-7.  $29.95.
  728.  
  729.      This is a fairly good book for beginning Mac programmers.  Experienced
  730.      programmers will find nothing new here.
  731.  
  732.  
  733. Programmer's Guide to MPW, Volume I
  734.    Addison-Wesley.  ISBN 0-201-57011-4.  $26.95.
  735.  
  736.      This is a basic introduction to using MPW.  I don't recommend it for
  737.      anyone who already uses MPW.
  738.  
  739.  
  740. Programming with MacApp
  741.    Addison-Wesley.  ISBN 0-201-09784-2.  $24.95.
  742. C++ Programming with MacApp
  743.    Addison-Wesley.  ISBN 0-201-57020-3.  $24.95.
  744.  
  745.      These give a basic introduction to programming with MacApp; the first
  746.      with Object Pascal, and the second with C++.
  747.  
  748.  
  749. Programming for System 7.
  750.    Addison-Wesley.  ISBN 0-201-56770-9.  $26.95
  751.  
  752.      This is a guide to creating applications for System 7.  It describes
  753.      the new features and functions of the operating system in detail.
  754.      The sample code is in C and includes a complete System 7 application
  755.      in Chapter 1 which is expanded in succeeding chapters.
  756.  
  757.  
  758. ResEdit Complete
  759.    Addison-Wesley.  ISBN 0-201-55075-X.  $29.95.
  760.  
  761.      Most of this book is not written for programmers, but includes quite
  762.      a bit of useful information nonetheless.  It contains detailed
  763.      discussions of using, customizing and programming ResEdit, including
  764.      the creation of custom templates, pickers and editors. It comes with
  765.      ResEdit 2.1 on disk, with sample source code in MPW C and Pascal.
  766.  
  767.  
  768. Debugging Macintosh Software with MacsBug
  769.    Addison-Wesley.  ISBN 0-201-57049-1.  $34.95.
  770.  
  771.      This looks like a really good and useful book, but I haven't had a
  772.      chance to look at it yet.  MacsBug is included on disk, along with
  773.      several examples and dcmds.
  774.  
  775.  
  776. Programming the M68000
  777.    Benjamin/Cummings.  ISBN 0-8053-5550-2.
  778. 680x0 Programming by Example
  779.    Howard W. Sams & Co.  ISBN 0-672-22544-1.  $17.95.
  780. M68000 Assembly Language: Techniques for Building Programs
  781.    Addison-Wesley.  ISBN 0-201-11659-6.
  782. The Complete Book of Macintosh Assembly Language Programming [sic]
  783.    Scott, Foresman & Co.
  784.    Vol I  ISBN 0-673-18379-3
  785.    Vol II ISBN 0-673-18583-4
  786.  
  787.      These are all assembly books that have been recommended by people on
  788.      the net.  The first two are general; the others are specific to the
  789.      Macintosh.
  790.  
  791.  
  792.  
  793. 3.1.3  Periodicals
  794. ------------------
  795.  
  796.  
  797. d e v e l o p
  798.    Quarterly.  $10 per issue.  $30 per year.
  799.    develop
  800.    Apple Computer, Inc.
  801.    P.O. Box 531
  802.    Mt. Morris, IL  61054
  803.    AppleLink DEV.SUBS
  804.  
  805.      develop is Apple's technical journal for the Macintosh and Apple II
  806.      (the focus is on the Mac).  The articles are well-written and useful,
  807.      and it includes the Developer CD.
  808.  
  809.  
  810. MacTech  (was MacTutor)
  811.    Monthly.  $5 per issue.  $40 per year Third Class; $55 First Class.
  812.     Xplain Corporation
  813.     P.O. Box 250055
  814.     Los Angeles, CA  90025-9555
  815.     Phone: (310) 575-4343
  816.       FAX: (310) 575-0925
  817.     mactutor@applelink.apple.com
  818.  
  819.      The only Macintosh programming journal that I'm aware of.  A good
  820.      source of sample code.
  821.  
  822.  
  823.  
  824.  
  825. 3.2  Mailing Lists
  826. ------------------
  827.  
  828. 3.2.1  Comp.Sys.Mac.Programmer Digest
  829. -------------------------------------
  830.  
  831. The Comp.Sys.Mac.Programmer Digest is a collection of article threads from
  832. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  833. regularly and want an archive of the discussions.
  834.  
  835. Each issue of the digest contains one or more sets of articles (called
  836. threads), with each set corresponding to a 'discussion' of a particular
  837. subject.  The articles are not edited; all articles included in the digest
  838. are in their original posted form (as received by the news server at
  839. cs.uoregon.edu).  Article threads are not added to the digest until the last
  840. article added to the thread is at least one month old (this is to ensure that
  841. the thread is dead before adding it to the digest).  Article threads that
  842. consist of only one message are generally not included in the digest.
  843.  
  844. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  845. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  846. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  847. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  848. has a mail server; send a message with the text '$MACarch help' (no quotes)
  849. to LISTSERV@ricevm1.rice.edu for more information.
  850.  
  851. The digest is also available via email.  Just send a note saying that you
  852. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  853. automatically receive each new issue as it is created.  Sorry, back issues
  854. are not available through the mailing list.
  855.  
  856.  
  857.  
  858.  
  859. 3.2.2  Think Class Library Discussion
  860. -------------------------------------
  861.  
  862. The Think Class Library discussion list is for those interested in using
  863. Symantec's Think C and Think Pascal object-oriented class library for
  864. Macintosh.  Discussion topics include
  865.  
  866.    * class usage, design, and implementation
  867.    * TCL bug reports, work-arounds, and fixes
  868.    * TCL application development techniques
  869.    * TCL development aids
  870.  
  871. Mail to the discussion list should be sent to tcl-talk@brown.edu.
  872. If you want to join the discussion list, mail a note saying so to
  873. tcl-request@brown.edu.
  874.  
  875.  
  876.  
  877.  
  878. 3.2.3  MacPsych
  879. ---------------
  880.  
  881. This is a mailing list of psychologists and others interested in using the
  882. Macintosh in research and teaching.  The intention of this service is to
  883. provide quick and authoritative answers to questions raised by Mac-using
  884. researchers and teachers in psychology.  Individuals who have Mac questions
  885. to pose, or have general messages that they believe would be of interest to
  886. research psychologists and teachers using the Macintosh, may send their
  887. information to macpsych@stolaf.edu.  Mail sent to this address will first
  888. pass through the moderator for the list (huff@stolaf.edu) who will forward
  889. it to everyone on the list.
  890.  
  891. If you want to be on the mailing list, mail a note saying so to
  892. macpsych-request@stolaf.edu.
  893.  
  894. There is an archive containing some free Macintosh software that has been
  895. written by members of the group; for more information, write to
  896. macpsych-request@stolaf.edu.
  897.  
  898.  
  899.  
  900.  
  901. 3.3  Miscellaneous
  902. ------------------
  903.  
  904. 3.3.1  Usenet Mac Programmer's Guide
  905. ------------------------------------
  906.  
  907. The Usenet Mac Programmer's Guide (UMPG) is a collection of useful tips
  908. culled  from comp.sys.mac.programmer.  Compiled by Matthew X. Mora
  909. (mxmora@unix.sri.com), it is organized by topic and includes a table of
  910. contents and index.  It is available via anonymous ftp from sumex-aim.
  911. stanford.edu (36.44.0.6) in the directory /info-mac/tech/.
  912.  
  913. It is also available in a pre-printed version, or on disk.
  914.  
  915. To get a copy of the printed version send $17.00 to:
  916.  
  917.      USENET Macintosh Programmer's Guide Printed Version
  918.      39075 Carmel Ct.
  919.      Fremont, CA  94538
  920.  
  921. To get a copy of the disk version send $5.00 to:
  922.  
  923.       USENET Macintosh Programmer's Guide Disk Version
  924.       39075 Carmel Ct.
  925.       Fremont, CA  94538
  926.  
  927.  
  928.  
  929.  
  930. 3.3.2  Kent Sandvik's Frequently Asked MPW C++ and MacApp Questions
  931. -------------------------------------------------------------------
  932.  
  933. This file is available upon request from ksand@apple.com or via anonymous ftp
  934. to ftp.cs.uoregon.edu [128.223.8.8] in the directory /pub/mac.
  935.  
  936.  
  937.  
  938.  
  939. 3.3.3  Comp.Sys.Mac.FAQ
  940. -----------------------
  941.  
  942. This Frequently Asked Questions list provides short answers to a number of
  943. frequently asked questions from the newsgroups comp.sys.mac.system,
  944. comp.sys.mac.misc, and comp.sys.mac.apps.  Some of the questions that it
  945. answers are asked occasionally on comp.sys.mac.programmer.  Please read
  946. this FAQ list before posting to c.s.m.p.  It is available from the sumex
  947. archives and its mirror sites (see section 4.2) in the file /info-mac/
  948. report/csmf-faq.txt.
  949.  
  950.  
  951.  
  952.  
  953.  
  954.                         =============================
  955.                           Section IV: Archive Sites
  956.                         =============================
  957.  
  958.  
  959. 4.1  ftp.apple.com [130.43.2.3]
  960. -------------------------------
  961.  
  962. Contents
  963.    This archive contains just about everything available for free from
  964.    Apple.  Look here first for sample source code, the latest tech
  965.    notes, and tools such as ResEdit and MacsBug.  Very little of what
  966.    can be found here is available from other archives.
  967.  
  968. Access
  969.    Anonymous ftp, from inside the United States only.
  970.    You should read the file /dts/README.FIRST before downloading from this
  971.    archive.  Everything for the Mac is in /dts/mac.  The moderators ask that
  972.    you download during the off-peak hours if at all possible, since this is
  973.    just a IIci running A/UX.
  974.  
  975. Submissions
  976.    You cannot post to this archive.
  977.  
  978.  
  979. 4.2  sumex-aim.stanford.edu [36.44.0.6]
  980. ---------------------------------------
  981.  
  982. Contents
  983.    This archive contains a large collection of public-domain and shareware
  984.    for the Mac.  It is well-maintained and updated regularly.  New
  985.    submissions to the archive are listed every other day or so in the
  986.    newsgroup comp.sys.mac.digest.
  987.  
  988. Access
  989.    Anonymous ftp.  Read the files in /info-mac/help for more detailed
  990.    information about the files in the archive.  Everything is in /info-mac.
  991.    If you don't have ftp access you can use the mail server; send a message
  992.    with the text '$MACarch help' (no quotes) to LISTSERV@ricevm1.rice.edu
  993.    for more information.
  994.  
  995. Submissions
  996.    Sumex accepts all submissions that "are of general benefit to the
  997.    Macintosh community."  Basically, if you have something that you think is
  998.    useful, and that other people may like to have, you should feel free to
  999.    send it to sumex.  All submissions should be compressed and BinHexed, and
  1000.    should include a short but informative blurb at the beginning of the file.
  1001.    Mail your submissions to info-mac@sumex-aim.stanford.edu.  For more
  1002.    detailed information, consult the file
  1003.        /info-mac/help/posting-guidelines.txt.
  1004.  
  1005.  
  1006. 4.3  rascal.ics.utexas.edu [128.83.138.20]
  1007. ------------------------------------------
  1008.  
  1009. This archive is being discontinued as of 5/92.  It will continue to have
  1010. stuff available for a while, perhaps a few months, but the contents will
  1011. eventually dwindle until there is very little or nothing left.
  1012.  
  1013. Contents
  1014.    This archive contains most of what can be found at sumex.  Its
  1015.    emphasis is on utilities and programming-related items, but it
  1016.    contains quite a bit of other stuff as well.  It is the home of
  1017.    the comp.sys.mac.announce archives.  Many items tend to appear
  1018.    here before they show up at sumex or comp.binaries.mac.
  1019.  
  1020. Access
  1021.    Anonymous ftp.
  1022.  
  1023. Submissions
  1024.    No longer accepted.
  1025.  
  1026.  
  1027. 4.4  mac.archive.umich.edu [141.211.164.153]
  1028. --------------------------------------------
  1029.  
  1030. Contents
  1031.    I haven't explored this archive yet, but I hear it has quite a bit
  1032.    of general Macintosh freeware and shareware.
  1033.  
  1034. Access
  1035.    Anonymous ftp.
  1036.  
  1037. Submissions
  1038.    You can submit to this archive by mailing a compressed, binhexed
  1039.    file with a brief descriptive header to macgifts@mac.archive.umich.
  1040.    edu.  This address will also forward your mail to comp.binaries.mac
  1041.    and sumex-aim.stanford.edu.
  1042.  
  1043.  
  1044. 4.5  ftp.cs.uoregon.edu [128.223.8.8]
  1045. -------------------------------------
  1046.  
  1047. Contents
  1048.    This is the home of this FAQ list, as well as the Comp.Sys.Mac.
  1049.    Programmer Digests.  There's also a little sample code not included
  1050.    in the FAQ.
  1051.  
  1052. Access
  1053.    Anonymous ftp.  Directory /pub/mac.
  1054.  
  1055. Submissions
  1056.    Not accepted.
  1057.  
  1058.  
  1059. 4.6  ics.uci.edu [128.195.1.1]
  1060. ------------------------------
  1061.  
  1062. Contents
  1063.    This archive has some Mac stuff, although not nearly as much as the
  1064.    major sites, such as sumex.  The main attraction is the Think C
  1065.    directory.  It contains the latest updates to Think C, as well as
  1066.    Think C related system extensions, fkeys, etc., and source code.
  1067.    Definitely worth checking out if you use Think C extensively.
  1068.  
  1069. Access
  1070.    Anonymous ftp.  Directory /mac.
  1071.  
  1072. Submissions
  1073.    Not accepted, I think.  Someone please correct me if I'm wrong.
  1074.  
  1075.  
  1076. 4.7  ftp.brown.edu [128.148.176.55]
  1077. -----------------------------------
  1078.  
  1079. Contents
  1080.    This is the home of the Think Class Library mailing list.  It includes
  1081.    TCL bug fixes and new classes, as well as an archive of the tcl-talk
  1082.    mailing list.
  1083.  
  1084. Access
  1085.    Anonymous ftp.  Directory /pub/tcl.
  1086.  
  1087. Submissions
  1088.    Submissions to the archive should be mailed to tcl-request@brown.edu or
  1089.    placed in the directory /incoming/tcl with accompanying mail to
  1090.    tcl-request.  Encode all submissions in BinHex 4.0 format and include a
  1091.    descriptive header.  Please do not redistribute Symantec's TCL source.
  1092.  
  1093.  
  1094. 4.8  comp.binaries.mac [newsgroup]
  1095. ----------------------------------
  1096.  
  1097. Contents
  1098.    This is a moderated newsgroup for distribution of Macintosh freeware
  1099.    and shareware.  Just about everything that gets sent to sumex and
  1100.    the other major archives gets sent here as well.
  1101.  
  1102. Access
  1103.    Subscribe to the newsgroup....
  1104.  
  1105. Submissions
  1106.    All files should be compressed and binhexed for mailing.  Posting
  1107.    to the newsgroup should automatically get your file mailed to the
  1108.    moderator.  If this does not happen on your system, you can mail
  1109.    your posting to the moderator yourself at macintosh@dhw68k.cts.com,
  1110.    or at dhw68k!bytebug@ics.uci.edu if the first address doesn't work.
  1111.    Expect a delay of as much as a month before your posting shows up
  1112.    on the newsgroup.
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.                           =========================
  1119.                             Section V: One-liners
  1120.                           =========================
  1121.  
  1122.  
  1123. 5.1  The Main Loop and Events
  1124. -----------------------------
  1125.  
  1126. Call MaxApplZone and MoreMasters when the application starts up.
  1127. If you call SetApplLimit, do it before calling MaxApplZone.
  1128. Use HD in MacsBug while running to estimate how many times to call
  1129. MoreMasters.
  1130. Don't use SetEventMask to disable mouseUp events.  Better not to use it at
  1131. all.
  1132. Call WaitNextEvent if you're running under System 6 or later.
  1133. DTS sample code passes 0x7fffffff to WaitNextEvent when nothing is happening.
  1134. DTS sample code passes GetCaretTime() to WaitNextEvent when flashing a
  1135. cursor.
  1136. Call both GetNextEvent and SystemTask only if WaitNextEvent is unavailable.
  1137. Call IsDialogEvents and DialogSelect even if GetNextEvent returns false.
  1138. SetPort to a known good grafPort once every time through the event loop.
  1139. Set the cursor on suspend and resume events.
  1140. Call GetDblTime to get the maximum time for a double click.
  1141. Measure double click time from mouse up to mouse down.
  1142.  
  1143.  
  1144. 5.2  Menus
  1145. ----------
  1146.  
  1147. Use SetItem to include meta characters literally in menus.
  1148. Prepend an ASCII 0 to a menu item to use a leading '-'.
  1149. Never make MENU resources purgeable.
  1150.  
  1151.  
  1152. 5.3  Resources
  1153. --------------
  1154.  
  1155. GetResource never produces resNotFound.  Check for a NIL handle instead.
  1156. To create a resource file, call HCreate, then HCreateResFile.
  1157. To open a resource file read-only for shared access, use HOpenResFile.
  1158. Don't leave ResLoad set to false.
  1159. GetResource on a dctb may return a non-resource copy of the dctb.
  1160.  
  1161.  
  1162. 5.4  Windows, Alerts, and Dialogs
  1163. ---------------------------------
  1164.  
  1165. Move and size windows to the bounding box of GetGrayRgn.
  1166. Hide scroll bars when deactivating a window.
  1167. Call DrawGrowIcon when activating or deactivating a window with a grow
  1168. region.
  1169. DrawGrowIcon does not check to see if the window has a grow region.
  1170. Call PenNormal before calling DrawGrowIcon.
  1171. itemHit will not be set when a dialog filter is called.
  1172. Use a disabled UserItem to draw the roundrect outline around the OK button.
  1173. ModalDialog assumes the dialog is already visible and in the front.
  1174. Use screenBits.bounds to center dialogs, alerts, etc. below the menu bar.
  1175. If you save window locations in files, they may not be valid for all
  1176. monitors.
  1177. DragWindow expects startPt in boundsRect; if not it may not call
  1178. SelectWindow.
  1179. SelectWindow does not automatically call SetPort.  You must do that yourself.
  1180. DialogSelect responds to activate events but ignores suspend/resume events.
  1181.  
  1182.  
  1183. 5.5  Drawing
  1184. ------------
  1185.  
  1186. Always set the VisRgn and ClipRgn of offscreen ports.
  1187. Set the ClipRgn first when making a picture.
  1188. Don't make rowBytes in bitMaps greater than 8191.
  1189. To dim text, draw a rectangle with penPat=gray and penMode=patbic over it.
  1190. To draw rotated text, draw to an offscreen bitmap, rotate it, and CopyBits
  1191. it.
  1192. Don't use picSize to determine the size of a picture.  Check the handle size.
  1193. Never draw outside a window except in XOR mode for temporary effects like
  1194. drag.
  1195. To avoid animation flicker, synchronize drawing to the vertical retrace.
  1196. CopyBits on more than 3Kb data will work, but it might have to allocate
  1197. memory.
  1198. The small Mac screen is 512 pixels wide by 342 pixels high including menu
  1199. bar.
  1200.  
  1201.  
  1202. 5.6  Files
  1203. ----------
  1204.  
  1205. Don't write in the application file.  This will fail with read-only devices.
  1206. Use PBGetVInfo to convert a VRefNum to a volume name.
  1207. Delete uses the Poor Man's Search Path, so don't delete blindly.
  1208. File Manager routines with dirID=0 use the Poor Man's Search Path.
  1209. Truncate and reallocate files before overwriting to reduce fragmentation.
  1210. Check/change the creator and type of Save As... files before overwriting.
  1211. If you rewrite files by deleting and creating, copy all Finder information.
  1212. Directory ID's are longs, not shorts.  Shorts work ALMOST all the time.
  1213. Always set the version number that appears in some file manager calls to 0.
  1214. To convert a pathRefNum to a name or file number, use PBGetFCBInfo.
  1215. Prevent the creation of files with names that begin with a period.
  1216.  
  1217.  
  1218. 5.7  Interrupts and VBL Tasks
  1219. -----------------------------
  1220.  
  1221. Don't call any Memory Manager routines during an interrupt.
  1222. Unlocked handles may not be valid during an interrupt.
  1223. To synchronize to the vertical retrace on Macs with slots use SlotVInstall.
  1224.  
  1225.  
  1226. 5.8  Handles and Pointers
  1227. -------------------------
  1228.  
  1229. Lock handles before passing their dereferenced pointers to any routine.
  1230. Lock handles before setting referenced data to expressions containing
  1231. functions
  1232. Put an odd long at location zero on a 68000 to help find NIL handle
  1233. references.
  1234. Use HGetState/HLock/HSetState to lock a handle then put it back as it was.
  1235.  
  1236.  
  1237. 5.9  General
  1238.  
  1239. Always use unsigned characters within text and Pascal-format strings.
  1240. Save application preferences in a folder named Preferences in the System
  1241. Folder
  1242. Use SysEnvirons to find the System (Blessed) Folder.
  1243. Use GetAppParms to get the name of the application.
  1244. The high bit of SysParam . volClik enables the alarm clock.
  1245. Check the application name at $910 before exiting with ES within MacsBug.
  1246. To exit to shell in the mini-debugger, enter SM 0 A9 F4 and then G 0.
  1247. In Pascal, don't nest procedures to be passed by procedure pointer.
  1248. In Pascal, "with theHandle^^" is unsafe if memory compaction can occur.
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.                        ==============================
  1255.                          Credits / Acknowledgements
  1256.                        ==============================
  1257.  
  1258.  
  1259. Many thanks to Ben Haller, who started this whole thing, and did quite a lot
  1260. of work on this posting before handing it off to Michael A. Kelly.  Many
  1261. thanks to Michael A. Kelly also, for all his work in establishing and
  1262. maintaining this FAQ (in addition to continuing to keep the
  1263. Comp.Sys.Mac.Programmer Digest) before passing the baton.
  1264.  
  1265. Thanks to these people for proofreading this list during its development:
  1266.     Ben Haller
  1267.     Wally Wedel
  1268.     John B. Matthews
  1269.     Patrick Beard
  1270.     Steve Zellers
  1271.  
  1272. Thanks to Chris Webster for the one-liners.
  1273.  
  1274. Thanks to Peter Lewis for the answers to the following specific questions:
  1275.     6.2.1  When do you put an ellipsis on the end of a menu item?
  1276.     6.5.1  Why is the File Manager so hard to use?
  1277.     6.5.2  How do you get a full pathname?
  1278.     6.5.3  How do you set the SFGet/PutFile directory?
  1279.  
  1280. Thanks to Greg Ferrar for the review on TMON Pro.
  1281.  
  1282. Thanks to John Rinaldo for the review on Jasik's Debugger.
  1283.  
  1284. Thanks for Fritz Anderson for his descriptions of SourceBug and the new
  1285. Inside Macintosh volumes.
  1286.  
  1287. And thanks to everyone who has offered suggestions or constructive
  1288. criticism....  Keep those comments coming!
  1289.  
  1290.  
  1291.  
  1292.  
  1293. --
  1294. -------------------------------------------------------------------
  1295.  Daryl_Spitzer@mindlink.bc.ca     "Life isn't just, life just is."
  1296.          a2251@mindlink.bc.ca              -- Me  (I think.)
  1297. -------------------------------------------------------------------
  1298. Archive-name: macintosh/programmer-faq/part2
  1299. Last-modified: 1993/01/12
  1300.  
  1301.  
  1302.                      +---------------------------------+
  1303.                      | Frequently Asked Questions List |
  1304.                      |   for Comp.Sys.Mac.Programmer   |
  1305.                      |         January 12, 1993        |
  1306.                      |            PART  TWO            |
  1307.                      +---------------------------------+
  1308.  
  1309.  
  1310. This FAQ list is automatically posted once a week to comp.sys.mac.programmer.
  1311. It is also available via anonymous ftp from ftp.cs.uoregon.edu [128.223.8.8]
  1312. (user name 'anonymous', your internet address as password) in the files
  1313. /pub/mac/csmp-faq-1 and /pub/mac/csmp-faq-2.
  1314.  
  1315. This FAQ list is maintained by Daryl Spitzer.  He can be reached at the
  1316. following addresses:
  1317.  
  1318.    Internet:  Daryl_Spitzer@mindlink.bc.ca
  1319.    SnailMail: 203 - 1385 West 12th Avenue
  1320.               Vancouver, BC  (Canada)
  1321.               V6H 1M2
  1322.  
  1323. The purpose of the FAQ list is to answer some of the most common questions
  1324. asked on this group, and to refer people left with unanswered questions to
  1325. available sources of additional help.  You should read the FAQ list before
  1326. posting to comp.sys.mac.programmer.
  1327.  
  1328. Submissions, comments, etcetera, should be sent to Daryl Spitzer, as above.
  1329. All such material sent will be considered to have entered the public domain
  1330. (and will be subject to editing) unless specific text to the contrary
  1331. accompanies the message (which may render the submission unusable).
  1332.  
  1333.  
  1334.  
  1335.                          Changes since August 3, 1992
  1336.                          ----------------------------
  1337.  
  1338.  - the keeper of the FAQ is now Daryl Spitzer (Daryl_Spitzer@mindlink.bc.ca)
  1339.  
  1340.  - 1.2  Debuggers:
  1341.     added Fritz Anderson's description of SourceBug
  1342.  
  1343.  - 2.1  The Associates and Partners Programs:
  1344.     new description, DEVHOTLINE is no longer a valid AppleLink address
  1345.  
  1346.  - 2.3  APDA
  1347.     new address and telephone numbers
  1348.  
  1349.  - 3.1.1  Technical Books
  1350.     new Inside Macintosh volumes
  1351.  
  1352.  - 3.1.3  Periodicals:
  1353.     MacTutor is now MacTech
  1354.  
  1355.  
  1356.  
  1357.  
  1358.                               Table of Contents
  1359.                               -----------------
  1360.  
  1361. Part One  (separate file)
  1362. ---------------------
  1363.  
  1364.   I.    Development Software
  1365.           1. Compilers
  1366.           2. Debuggers
  1367.           3. Other Tools
  1368.  
  1369.   II.   Apple Developer Programs
  1370.           1. The Associates and Partners Programs
  1371.           2. Apple Developer University
  1372.           3. APDA
  1373.           4. Developer CDs
  1374.  
  1375.   III.  Sources of Information
  1376.           1. Books and Periodicals
  1377.                1. Technical Books
  1378.                2. Teaching Books
  1379.                3. Periodicals
  1380.           2. Mailing Lists
  1381.                1. Comp.Sys.Mac.Programmer Digest
  1382.                2. Think Class Library Discussion
  1383.                3. MacPsych
  1384.           3. Miscellaneous
  1385.                1. Usenet Mac Programmer's Guide (UMPG)
  1386.                2. Kent Sandvik's Frequently Asked MPW C++ and MacApp
  1387. Questions
  1388.                3. Comp.Sys.Mac.FAQ
  1389.  
  1390.   IV.   Archive Sites
  1391.           1. ftp.apple.com [130.43.2.3]
  1392.           2. sumex-aim.stanford.edu [36.44.0.6]
  1393.           3. rascal.ics.utexas.edu [128.83.138.20]
  1394.           4. mac.archive.umich.edu [141.211.164.153]
  1395.           5. ftp.cs.uoregon.edu [128.223.8.8]
  1396.           6. ics.uci.edu [128.195.1.1]
  1397.           7. ftp.brown.edu [128.148.176.55]
  1398.           8. comp.binaries.mac [newsgroup]
  1399.  
  1400.   V.    One-liners
  1401.           1. The Main Loop and Events
  1402.           2. Menus
  1403.           3. Resources
  1404.           4. Windows, Alerts, and Dialogs
  1405.           5. Drawing
  1406.           6. Files
  1407.           7. Interrupts and VBL Tasks
  1408.           8. Handles and Pointers
  1409.           9. General
  1410.  
  1411.  
  1412. Part Two  (this file)
  1413. -------------------------
  1414.  
  1415.   VI.   Specific Questions Answered
  1416.           1. The Main Loop and Events
  1417.                1. How do you tell if a specific key is being pressed?
  1418.                2. How can I get millisecond timing from the keyboard
  1419.                   (or mouse)?
  1420.           2. Menus
  1421.                1. When do you put an ellipsis on the end of a menu item?
  1422.                2. How do I get the menubar to disappear and re-appear?
  1423.                3. What's the difference between the resource ID of a 'MENU'
  1424.                   resource and the menuID field of that resource?
  1425.           3. Windows, Alerts, and Dialogs
  1426.                1. How do you put a border around the default button in a
  1427.                   dialog?
  1428.           4. Drawing
  1429.                1. What is the fastest way to paint one pixel on the screen?
  1430.                2. How do you draw directly into a pixmap without using
  1431.                   QuickDraw?
  1432.                3. How do you draw directly onto the screen without using
  1433.                   QuickDraw?
  1434.                4. What RGB value does the system use for dimmed buttons,
  1435.                   menus and window titles?
  1436.           5. Files
  1437.                1. Why is the File Manager so hard to use?
  1438.                2. How do you get a full pathname?
  1439.                3. How do you set the SFGet/PutFile directory?
  1440.                4. How do you access the application's data fork?
  1441.           6. Handles and Pointers
  1442.                1. When should I call MoveHHi?
  1443.                2. Why does malloc/calloc keep crashing or returning NULL in
  1444.                   Think C?
  1445.           7. Standalone Code
  1446.                1. How do I write an INIT?
  1447.           8. General
  1448.                1. How do I register signatures and file types with Apple?
  1449.                2. How do I go about writing serial port communications?
  1450.  
  1451.  
  1452.   VII.  Eternal Debates:
  1453.           1. Why doesn't the Mac do preemptive multitasking?
  1454.  
  1455.  
  1456.  
  1457. =============================================================================
  1458.  
  1459.  
  1460.                  ===========================================
  1461.                    Section VI: Specific Questions Answered
  1462.                  ===========================================
  1463.  
  1464.  
  1465.  
  1466. 6.1  The Main Loop and Events
  1467. -----------------------------
  1468.  
  1469.  
  1470. ----------------------------------------------------------
  1471. 6.1.1  How do you tell if a specific key is being pressed?
  1472. ----------------------------------------------------------
  1473.  
  1474. Use GetKeys.  GetKeys fills a 16-byte KeyMap structure with the state of
  1475. every key.  Each bit represents a single key on the keyboard; 1 means the
  1476. key is down, 0 means it is up.  Note that there can be a maximum of seven
  1477. keys being pressed at a time - any of the modifier keys plus at most two
  1478. other keys.
  1479.  
  1480. Here's an example in C:
  1481.  
  1482. Boolean IsKeyDown(
  1483.     unsigned short theKey )  // a keyboard-specific scan code for a key
  1484. {
  1485.  
  1486.     unsigned char  keyMap[16];
  1487.  
  1488.     GetKeys( (void *) keyMap );
  1489.     return ((keyMap[theKey>>3] >> (theKey & 7)) & 1);
  1490.  
  1491. }
  1492.  
  1493.  
  1494.  
  1495. -----------------------------------------------------------------------------
  1496. 6.1.2  I'm writing a psychology experiment.  How can I get millisecond timing
  1497.        from the keyboard (or mouse)?
  1498. -----------------------------------------------------------------------------
  1499.  
  1500. The simple answer is that you can't.  Although the new time manager can call
  1501. routines every couple of microseconds, input goes through the event manager,
  1502. which only posts events about every 16 milliseconds.  Thus, even if you poll
  1503. the keyboard every 30 microseconds, you will not get better than 16 ms.
  1504. resolution.  If you really need millisecond accuracy, you need to use
  1505. external hardware.
  1506.  
  1507. The good news is that you probably don't need better than 16 ms. resolution
  1508. anyway.  Measuring with 16 ms. accuracy only increases the standard deviation
  1509. of your RT means by about 4.8 msec.  Read: Ulrich, R. and Giray, M. (1989).
  1510. Time resolution of clocks: Effects on reaction time measurement -- Good news
  1511. for bad clocks.  British Journal of Mathematical and Statistical Psychology,
  1512. 42, 1-12.
  1513.  
  1514. By the way, there is a mailing list dedicated to running psychology
  1515. experiments on the Mac.  It frequently gets tied up in arguments about
  1516. millisecond timing.  The address to write to is macpsych-request@stolaf.edu.
  1517.  
  1518.  
  1519.  
  1520.  
  1521. 6.2  Menus
  1522. ----------
  1523.  
  1524.  
  1525. -------------------------------------------------------------
  1526. 6.2.1  When do you put an ellipsis on the end of a menu item?
  1527. -------------------------------------------------------------
  1528.  
  1529. Put an ellipsis (...) at the end of any menu item which requires more
  1530. information in order to complete or simply displays information.  Usually
  1531. this involves a dialog of some kind, be it modal or non modal.
  1532.  
  1533.  
  1534.  
  1535. -----------------------------------------------------------
  1536. 6.2.2  How do I get the menubar to disappear and re-appear?
  1537. -----------------------------------------------------------
  1538.  
  1539. A set of routines to do this in Pascal can be found in the Usenet
  1540. Macintosh Programmer's Guide.  You can also ftp some sample code in C
  1541. from skinner.cs.uoregon.edu in /pub/mac/menu-bar.c.
  1542.  
  1543.  
  1544.  
  1545. -----------------------------------------------------------------------------
  1546. 6.2.3  What's the difference between the resource ID of a 'MENU' resource and
  1547.        the menuID field of that resource?
  1548. -----------------------------------------------------------------------------
  1549.  
  1550. The resource ID of a 'MENU' resource is just the resource ID - it has no
  1551. hidden meaning.  What is normally expected by beginning programmers is that
  1552. the number that MenuSelect and MenuKey return is the resource ID of the menu.
  1553. In fact, the number returned is the value of the menuID field of the menu,
  1554. and has no relation to the resource ID of the menu.  You can set the menuID
  1555. to any number you want, but by convention it is expected to be the same as
  1556. the resource ID of the menu.  (You can change this value in ResEdit by
  1557. opening the menu you wish to change, and selecting 'Edit Menu & MDEF ID...'
  1558. from the MENU menu.)
  1559.  
  1560.  
  1561.  
  1562.  
  1563. 6.3  Windows, Alerts, and Dialogs
  1564. ---------------------------------
  1565.  
  1566.  
  1567. ---------------------------------------------------------------------
  1568. 6.3.1  How do you put a border around the default button in a dialog?
  1569. ---------------------------------------------------------------------
  1570.  
  1571. The most common way to do this is to create a dummy user item in the dialog,
  1572. and use SetDItem to install a procedure that outlines the default button.
  1573. The dialog's "Initially visible" bit should be false and you should call
  1574. ShowWindow before calling ModalDialog; otherwise, if the button is very tall,
  1575. part of the outline won't be drawn.  Here is an example in C:
  1576.  
  1577.  
  1578. /* This function draws a border around dialog item #1 */
  1579.  
  1580. pascal void OutlineDefault(
  1581.     DialogPtr theDialog,
  1582.     short     theItem )
  1583. {
  1584.  
  1585.     Rect     itemRect;
  1586.     Handle   itemHandle;
  1587.     short    itemType;
  1588.     short    diameter;
  1589.  
  1590.     GetDItem( theDialog, 1, &itemType, &itemHandle, &itemRect );
  1591.     diameter = (itemRect.bottom - itemRect.top) / 2 + 6;
  1592.     if ( diameter < 16 )
  1593.         diameter = 16;
  1594.     PenSize( 3, 3 );
  1595.     InsetRect( &itemRect, -4, -4 );
  1596.     FrameRoundRect( &itemRect, diameter, diameter );
  1597.  
  1598. }
  1599.  
  1600.  
  1601.  
  1602. /* Assume myDialog has been initialized, and item #4 is the dummy
  1603.    user item for outlining the default button.  The following lines
  1604.    install the outlining procedure OutlineDefault into the user
  1605.    item, so that OutlineDefault will be called by the Dialog Manager
  1606.    each time the dialog needs to be redrawn.  Depending on your
  1607.    compiler, you may have to cast OutlineDefault to a Handle. */
  1608.  
  1609. GetDItem( myDialog, 4, &itemType, &itemHandle, &itemRect );
  1610. SetDItem( myDialog, 4, itemType, OutlineDefault, &itemRect );
  1611.  
  1612.  
  1613.  
  1614.  
  1615. 6.4  Drawing
  1616. ------------
  1617.  
  1618.  
  1619. ----------------------------------------------------------------
  1620. 6.4.1  What is the fastest way to paint one pixel on the screen?
  1621. ----------------------------------------------------------------
  1622.  
  1623. Using QuickDraw, the fastest way to draw one pixel is
  1624.    MoveTo( x, y );
  1625.    Line( 0, 0 );
  1626. making sure that the pen size is 1 by 1.  This is about twice as fast as
  1627. setting the pen size to 0 by 1 or 1 by 0 and calling Line( 1, 0 ) or
  1628. Line( 0, 1 ), respectively.  I'm not sure why....
  1629.  
  1630. See below for how to draw a pixel without using QuickDraw.
  1631.  
  1632.  
  1633.  
  1634. ----------------------------------------------------------------------
  1635. 6.4.2  How do you draw directly into a pixmap without using QuickDraw?
  1636. ----------------------------------------------------------------------
  1637.  
  1638. As an example, here is a routine that paints a single pixel in a pixmap.
  1639. To use this procedure, you just have to know what 'value' to pass in.  This
  1640. depends on the current bit-depth of 'thePixMap.'  The rightmost n bits of
  1641. 'value' are used for the pixel value for depth = n.  For depths of eight or
  1642. less, the value of each pixel is an index into a color table.  For depth =
  1643. 16,
  1644. each 16-bit pixel is interpreted as an RGB value, as follows:
  1645.  
  1646.          Bit: 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  1647.        Value:  R  R  R  R  R  G  G  G  G  G  B  B  B  B  B  U
  1648.  
  1649. where R = Red, G = Green, B = Blue, and U = Unused.  For depth = 32, each
  1650. 32-bit pixel is interpreted as an RGB value as follows:
  1651.  
  1652.          Bit: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  1653.        Value:  A  A  A  A  A  A  A  A  R  R  R  R  R  R  R  R
  1654.  
  1655.          Bit: 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  1656.        Value:  G  G  G  G  G  G  G  G  B  B  B  B  B  B  B  B
  1657.  
  1658. where R = Red, G = Green, B = Blue, and A = Alpha.
  1659.  
  1660.  
  1661.  
  1662. void SetPixel(
  1663.     short           x,
  1664.     short           y,
  1665.     long            value,
  1666.     PixMapHandle    thePixMap )
  1667. {
  1668.  
  1669.     unsigned long   rowBytes;
  1670.     unsigned char   mask;
  1671.     unsigned char   shiftBits;
  1672.     unsigned char   *thePixel;
  1673.     unsigned char   pixelDepth;
  1674.     char            mode = true32b;
  1675.     Boolean         swapMode;
  1676.         swapMode = PixMap32Bit( thePixMap );
  1677.  
  1678.     LockPixels( thePixMap );
  1679.  
  1680.     rowBytes = (unsigned long) ((*thePixMap)->rowBytes & 0x1fff);
  1681.     thePixel = (unsigned char *) GetPixBaseAddr( thePixMap );
  1682.  
  1683.     pixelDepth = (*thePixMap)->pixelSize;
  1684.  
  1685.     switch ( pixelDepth ) {
  1686.             case 1:
  1687.         case 2:
  1688.         case 4:
  1689.         case 8:
  1690.  
  1691.             thePixel += (rowBytes * y) +
  1692.                         (((unsigned long) pixelDepth * x) / 8L);
  1693.  
  1694.             shiftBits = ((8 - pixelDepth) - ((x * pixelDepth) % 8));
  1695.  
  1696.             mask = (unsigned char) ((1 << pixelDepth) - 1) << shiftBits;
  1697.  
  1698.             if ( swapMode ) {
  1699.                 SwapMMUMode( &mode );
  1700.             }
  1701.  
  1702.             *thePixel &= ~mask;
  1703.             *thePixel |= (unsigned char) value << shiftBits;
  1704.  
  1705.             break;
  1706.  
  1707.  
  1708.         case 16:
  1709.  
  1710.             thePixel += (rowBytes * y) + (2L * x);
  1711.  
  1712.             if ( swapMode ) {
  1713.                 SwapMMUMode( &mode );
  1714.             }
  1715.  
  1716.             *((unsigned short *)thePixel) = (unsigned short) value;
  1717.  
  1718.             break;
  1719.  
  1720.  
  1721.         case 32:
  1722.  
  1723.             thePixel += (rowBytes * y) + (4L * x);
  1724.  
  1725.             if ( swapMode ) {
  1726.                 SwapMMUMode( &mode );
  1727.             }
  1728.  
  1729.             *((unsigned long *)thePixel) = value;
  1730.  
  1731.             break;
  1732.  
  1733.  
  1734.         default:
  1735.             break;
  1736.  
  1737.     }
  1738.  
  1739.     if ( swapMode ) {
  1740.         SwapMMUMode( &mode );
  1741.     }
  1742.  
  1743.     UnlockPixels( thePixMap );
  1744.  
  1745. }
  1746.  
  1747.  
  1748.  
  1749. ------------------------------------------------------------------------
  1750. 6.4.3  How do you draw directly onto the screen without using QuickDraw?
  1751. ------------------------------------------------------------------------
  1752.  
  1753. Get the pixmap for the monitor that you want to draw on, and send it to the
  1754. above procedure.  For example, to draw a red dot at position 10,10 on the
  1755. main screen (if the main screen is in 32-bit mode):
  1756.  
  1757.    GDHandle   theDevice;
  1758.  
  1759.    theDevice = GetMainDevice();
  1760.  
  1761.    SetPixel( x, y, 0x00FF0000, (*theDevice)->gdPMap );
  1762.  
  1763. If you are drawing directly to the screen, you should always wrap your
  1764. drawing with calls to ShieldCursor and ShowCursor.  Some monitors such
  1765. as the Radius Pivot series keep a virtual screen, and they don't update
  1766. the real screen unless they have to.  When you write directly to the
  1767. screen, you're actually writing to the virtual screen, and your drawing
  1768. won't show up on the real screen until the system has some other reason
  1769. to update the monitor.  Calling ShieldCursor each time you draw will
  1770. force these systems to update the real screen when you expect them to.
  1771.  
  1772.  
  1773.  
  1774. -----------------------------------------------------------------------
  1775. 6.4.4  What RGB value does the system use for dimmed buttons, menus and
  1776.        window titles?
  1777. -----------------------------------------------------------------------
  1778.  
  1779. The gray color does not have a fixed RGB value.  It is a weighted average of
  1780. the foreground and background colors.  To obtain the appropriate 'gray' color
  1781. for a given foreground and background color, use the Palette Manager routine
  1782. GetGray (documented in Inside Macintosh Volume VI).
  1783.  
  1784. pascal Boolean GetGray( GDHandle device, const RGBColor *backGround,
  1785.                         RGBColor *foreGround )
  1786.   = {0x303C,0x1219,0xAAA2};
  1787.  
  1788. If at least one gray or intermediate color is available, GetGray stores the
  1789. color in foreGround and returns true.  If no gray is available, or, if you
  1790. supplied two colors, no third distinguishable color is available, the
  1791. foreGround parameter is unchanged and the function returns false.
  1792.  
  1793. GetGray is not available in older versions of the system.  Use Gestalt to
  1794. determine whether it is available.
  1795.  
  1796.  
  1797.  
  1798.  
  1799. 6.5  Files
  1800. ----------
  1801.  
  1802.  
  1803. ----------------------------------------------
  1804. 6.5.1  Why is the File Manager so hard to use?
  1805. ----------------------------------------------
  1806.  
  1807. Its always those pesky wdrn's that are the problem.  Here is a summary of
  1808. some of the things to know:
  1809.  
  1810.     vrn = volume reference number
  1811.           (small negative number; e.g. -2)
  1812.     wdrn = working directory reference number
  1813.            (large negative number; e.g. -32123)
  1814.     dirID = directory ID
  1815.             (small (but long integer!) positive number; e.g. 4123)
  1816.  
  1817.     - vrn's and wdrn's can be used interchangably for the most part.
  1818.     - A vrn represents either a volume, or the root directory of a volume.
  1819.     - A wdrn represents a directory on a volume.
  1820.     - A dirID represents nothing without a vrn or a wdrn.
  1821.     - A dirID overrides the directory otherwise specified by the vrn or wdrn
  1822.       unless it's zero, in which case it's ignored.  If it is 2 it specifies
  1823.       the root directory of the volume.
  1824.     - You should always use vrn,dirID pairs. To convert a wdrn into a
  1825.       vrn,dirID pair use GetWDInfo, which returns the vRefNum, the dirID and
  1826.       the procID of the wdRefNum.  The procID is almost always 'ERIK'.
  1827.     - You can also use GetVol/SetVol to convert volume names to/from vrns.
  1828.     - To store a vrn,dirID pair (between invocations of a program) convert
  1829.       the vrn to a volume name & creation date (for verification) and store
  1830.       them and the dirID (and a filename perhaps).
  1831.  
  1832.  
  1833.  
  1834. --------------------------------------
  1835. 6.5.2  How do you get a full pathname?
  1836. --------------------------------------
  1837.  
  1838. Take a look at Tech Note #238, available from APDA (and other places).  It
  1839. tells you everything you need to know to get a full pathname, and why you
  1840. should, in general, use a volume name, dirID, filename (and perhaps volume
  1841. creation date) triple instead.  Also check out the code snippets available
  1842. from ftp.apple.com et al.  There are a couple of snippets that give code to
  1843. get a full pathname, as well as many other cool file manager tricks.
  1844.  
  1845.  
  1846.  
  1847. --------------------------------------------------
  1848. 6.5.3  How do you set the SFGet/PutFile directory?
  1849. --------------------------------------------------
  1850.  
  1851. To set the directory that is displayed by SFGet/PutFile, stuff the volume
  1852. reference number into SFSaveDisk, and the dirID into CurDirStore.
  1853.  
  1854.      CurDirStore = $398;   Current dirID from Standard File (long)
  1855.      SFSaveDisk = $214;    Negative of current vRefNum
  1856.  
  1857.  
  1858.  
  1859. -----------------------------------------------------
  1860. 6.5.3  How do you access the application's data fork?
  1861. -----------------------------------------------------
  1862.  
  1863. Call CurResFile when the application starts up.
  1864. Call PBGetFCBInfo to convert that refNum into a vRefNum, dirID and name.
  1865. Call HOpen with the vRefNum, dirID, and name to open up your data fork.
  1866.  
  1867.  
  1868.  
  1869.  
  1870. 6.6  Handles and Pointers
  1871. -------------------------
  1872.  
  1873.  
  1874. ----------------------------------
  1875. 6.6.1  When should I call MoveHHi?
  1876. ----------------------------------
  1877.  
  1878. MoveHHi is an expensive operation; calling it when you don't need to can
  1879. significantly slow down your program.  Additionally, over-calling of MoveHHi
  1880. can fragment the top of your heap.  Call MoveHHi before locking a handle that
  1881. is followed by some memory allocation.  To efficiently move a handle high in
  1882. the heap and then lock it, you might want to call HLockHi, a call new with
  1883. MPW 3.2 and THINK C 5.0 (probably THINK Pascal 4.0 as well).
  1884.  
  1885.  
  1886.  
  1887. -------------------------------------------------------------------------
  1888. 6.6.2  Why does malloc/calloc keep crashing or returning NULL in Think C?
  1889. -------------------------------------------------------------------------
  1890.  
  1891. #include <stdlib.h>
  1892.  
  1893. Explanation:  In THINK C, parameters and return values are 2-byte ints by
  1894. default, which causes the value passed to malloc to be $10000 times as large
  1895. as you think it is, and causes the upper bytes of the return value to be
  1896. zeroed.  Including stdlib includes a prototype which overrides the defaults.
  1897.  
  1898. Another common cause of problems with malloc is overwriting the end of a
  1899. string, such as only mallocing the size of the string and then writing the
  1900. string plus a null into the malloc'd space.  Think's malloc algorithm stores
  1901. block size information in space adjacent to the storage it allocates, so
  1902. overwriting the storage tends to cause havoc. The problem may not show
  1903. immediately since it will probably be the next malloc that encounters
  1904. problems.
  1905.  
  1906.  
  1907.  
  1908.  
  1909. 6.7  Standalone Code
  1910. --------------------
  1911.  
  1912.  
  1913. ------------------------------
  1914. 6.7.1  How do I write an INIT?
  1915. ------------------------------
  1916.  
  1917. There is a simple INIT (SetWindow INIT) with source code and explanations in
  1918. the Usenet Macintosh Programmer's Guide.  There is also a chapter on writing
  1919. system extensions in Macintosh Programming Secrets (2nd Ed.).  Be sure to
  1920. check out the ftp sites (especially ftp.apple.com) for sample inits.
  1921.  
  1922.  
  1923.  
  1924.  
  1925. 6.8  General
  1926. ------------
  1927.  
  1928.  
  1929. --------------------------------------------------------------
  1930. 6.8.1  How do I register signatures and file types with Apple?
  1931. --------------------------------------------------------------
  1932.  
  1933. Registering a signature and file type is free, and you don't have to be an
  1934. Apple Partner or Associate.  You can ftp the registration form from
  1935. ftp.apple.com; it's available as
  1936.      /dts/mac/registration/creator-file-type-form.txt.
  1937.  
  1938.  
  1939.  
  1940. -------------------------------------------------------------------------
  1941. 6.8.2  How do I go about writing serial port communications?
  1942.  
  1943. These days, it is best to use the new Comunications Toolbox (CTB).  By
  1944. utiizing the CTB, you will be able to write your code to a single
  1945. specification, and the code will work with all current CTB "tools" and all
  1946. future CTB tools. The CTB tools allow programmers to extend the CTB's
  1947. functionality. There is a tool for each facet of the communications puzzle:
  1948. Connection Tools, Terminal Tools, and File Transfer Tools.
  1949.  
  1950. For example, once I have written a piece of code that uses the Serial tool to
  1951. connect me to a terminal server, combined with the VT102 Tool to emulate a
  1952. vt102 terminal, and the XMODEM Macbinary Tool to transfer files, the same
  1953. code will work with Apple Modem Tool, TCP/IP, AppleTalk ADSP, ISDN, X.25, and
  1954. all future Connection Tools. Further, the terminal can emulate a VT320,
  1955. ASCII, or other terminals. Files may be transfered with XMODEM, TEXT, and
  1956. soon ZMODEM and Kermit protocols.
  1957.  
  1958. The disadvantage of the CTB is that you must limit yourself to the
  1959. specification of the Connection, Terminal, and File Transfer interfaces.
  1960. These limitations are *rarely* a problem, but clearly something like a FAX
  1961. interface program or real time data analyzer, would have to seriously
  1962. consider the interfaces before committing.
  1963.  
  1964. For most standard communications applications, such as terminal emulators,
  1965. Bulletin Board Systems, etc., the CTB is the correct choice.
  1966.  
  1967. You can only get the CTB development kit from APDA.  It is affordable,
  1968. somewhere just under $100.  This includes working sample code.
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.                       ================================
  1975.                         Section VII: Eternal Debates
  1976.                       ================================
  1977.  
  1978.  
  1979. These questions have no final answers.  They pop up every few months and
  1980. waste a tremendous amount of valuable network resources on discussions
  1981. that will never be resolved.  Most people would be happy if they were
  1982. never discussed again in this newsgroup.
  1983.  
  1984.  
  1985. 7.1  Why doesn't the Mac do preemptive multitasking?
  1986. ----------------------------------------------------
  1987.  
  1988. Pro-preemptives claim the current scheme is too vulnerable to ill-behaved
  1989. applications and too much trouble for application writers.  Anti-
  1990. preemptives claim that preemptive multitasking would reduce interactive
  1991. response, and that the current cooperative system works well.
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.                        ==============================
  1998.                          Credits / Acknowledgements
  1999.                        ==============================
  2000.  
  2001.  
  2002. Many thanks to Ben Haller, who started this whole thing, and did quite a lot
  2003. of work on this posting before handing it off to Michael A. Kelly.  Many
  2004. thanks to Michael A. Kelly also, for all his work in establishing and
  2005. maintaining this FAQ (in addition to continuing to keep the
  2006. Comp.Sys.Mac.Programmer Digest) before passing the baton.
  2007.  
  2008. Thanks to these people for proofreading this list during its development:
  2009.     Ben Haller
  2010.     Wally Wedel
  2011.     John B. Matthews
  2012.     Patrick Beard
  2013.     Steve Zellers
  2014.  
  2015. Thanks to Chris Webster for the one-liners.
  2016.  
  2017. Thanks to Peter Lewis for the answers to the following specific questions:
  2018.     6.2.1  When do you put an ellipsis on the end of a menu item?
  2019.     6.5.1  Why is the File Manager so hard to use?
  2020.     6.5.2  How do you get a full pathname?
  2021.     6.5.3  How do you set the SFGet/PutFile directory?
  2022.  
  2023. Thanks to Greg Ferrar for the review on TMON Pro.
  2024.  
  2025. Thanks to John Rinaldo for the review on Jasik's Debugger.
  2026.  
  2027. Thanks for Fritz Anderson for his descriptions of SourceBug and the new
  2028. Inside Macintosh volumes.
  2029.  
  2030. And thanks to everyone who has offered suggestions or constructive
  2031. criticism....  Keep those comments coming!
  2032.  
  2033.  
  2034.  
  2035.  
  2036. --
  2037. -------------------------------------------------------------------
  2038.  Daryl_Spitzer@mindlink.bc.ca     "Life isn't just, life just is."
  2039.          a2251@mindlink.bc.ca              -- Me  (I think.)
  2040. -------------------------------------------------------------------
  2041.